<?php
/**
 * @Notes:【】
 * @User: zwc
 * @Date: 2022-05-10 20:55
 */

namespace App\Util;

use Firebase\JWT\JWT;

class JwtAuth
{

    protected $token;
    
    /**
     * 解析token
     * @param string $jwt
     * @return array
     */
    public function parseToken(string $jwt): array
    {
        $this->token = $jwt;
        list($headb64, $bodyb64, $cryptob64) = explode('.', $this->token);
        $payload = JWT::jsonDecode(JWT::urlsafeB64Decode($bodyb64));
        return [$payload->jti->id, $payload->jti->type];
    }
}